+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
+Sun Jul 2 17:06:40 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkcalendar.c gtk/gtkclist.c gtk/gtkctree.c gtk/gtkhscale.c
+ gtk/gtkprogressbar.c gtk/gtkscale.c gtk/gtkvscale.c gtk/gtkaccellabel.c: Use
+ pango_layout_get_pixel_extents() to remove a large number of '/ PANGO_SCALE'.
+
+ * gtk/gtk[hv]ruler.c gtk/gtklabel.c: replace some / PANGO_SCALE with
+ PANGO_PIXELS() macro.
+
+Sun Jul 2 15:24:41 2000 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkwidget.[ch] (gtk_widget_get_pango_context): Add new function
+ that returns a PangoContext owned by the widget and updated to
+ match future changes in the widget. Also, make
+ gtk_widget_create_pango_layout() use this context. If we ever
+ add a ::changed signal to PangoContext, this will make things
+ much more convenient.
+
+ * gtk/gtkentry.c gtk/gtklabel.c: Call pango_layout_context_changed()
+ in the appropriate places instead of destroying the layouts and
+ creating new ones.
+
+ * gtk/gtkfontsel.[ch] gtk/gtkclist.c: Use gtk_widget_get_pango_context()
+ in a few strategic places.
+
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
{
GtkAccelLabel *accel_label;
PangoLayout *layout;
- PangoRectangle logical_rect;
+ gint width;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ACCEL_LABEL (widget));
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, accel_label->accel_string, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+ accel_label->accel_string_width = width;
- accel_label->accel_string_width = logical_rect.width / PANGO_SCALE;
g_object_unref (G_OBJECT (layout));
}
for (i = 0; i < 12; i++)
{
pango_layout_set_text (layout, default_monthname[i], -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->max_month_width = MAX (private_data->max_month_width,
- logical_rect.width / PANGO_SCALE + 8);
- max_header_height = MAX (max_header_height, logical_rect.height / PANGO_SCALE);
+ logical_rect.width + 8);
+ max_header_height = MAX (max_header_height, logical_rect.height);
}
private_data->max_year_width = 0;
for (i=0; i<10; i++)
{
sprintf (buffer, "%d%d%d%d", i,i,i,i);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->max_year_width = MAX (private_data->max_year_width,
- logical_rect.width / PANGO_SCALE + 8);
- max_header_height = MAX (max_header_height, logical_rect.height / PANGO_SCALE);
+ logical_rect.width + 8);
+ max_header_height = MAX (max_header_height, logical_rect.height);
}
}
else
{
sprintf (buffer, "%d%d", i, i);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->min_day_width = MAX (private_data->max_day_char_width,
- logical_rect.width / PANGO_SCALE);
+ logical_rect.width);
private_data->max_day_char_ascent = MAX (private_data->max_label_char_ascent,
- PANGO_ASCENT (logical_rect) / PANGO_SCALE);
+ PANGO_ASCENT (logical_rect));
private_data->max_day_char_descent = MAX (private_data->max_label_char_descent,
- PANGO_DESCENT (logical_rect) / PANGO_SCALE);
+ PANGO_DESCENT (logical_rect));
}
/* We add one to max_day_char_width to be able to make the marked day "bold" */
private_data->max_day_char_width = private_data->min_day_width / 2 +1;
for (i = 0; i < 7; i++)
{
pango_layout_set_text (layout, default_abbreviated_dayname[i], -1);
- pango_layout_line_get_extents (pango_layout_get_lines (layout)->data, NULL, &logical_rect);
+ pango_layout_line_get_pixel_extents (pango_layout_get_lines (layout)->data, NULL, &logical_rect);
- private_data->min_day_width = MAX (private_data->min_day_width, logical_rect.width / PANGO_SCALE);
+ private_data->min_day_width = MAX (private_data->min_day_width, logical_rect.width);
private_data->max_label_char_ascent = MAX (private_data->max_label_char_ascent,
- PANGO_ASCENT (logical_rect) / PANGO_SCALE);
+ PANGO_ASCENT (logical_rect));
private_data->max_label_char_descent = MAX (private_data->max_label_char_descent,
- PANGO_DESCENT (logical_rect) / PANGO_SCALE);
+ PANGO_DESCENT (logical_rect));
}
private_data->max_week_char_width = 0;
{
sprintf (buffer, "%d%d", i, i);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
private_data->max_week_char_width = MAX (private_data->max_week_char_width,
- logical_rect.width / PANGO_SCALE / 2);
+ logical_rect.width / 2);
}
main_width = (7 * (private_data->min_day_width + DAY_XPAD * 2) + (DAY_XSEP * 6) + CALENDAR_MARGIN * 2
sprintf (buffer, "%d", calendar->year);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
/* Draw title */
- y = (private_data->header_h - logical_rect.height / PANGO_SCALE) / 2;
+ y = (private_data->header_h - logical_rect.height) / 2;
/* Draw year and its arrows */
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
x = header_width - (3 + max_year_width
- - (max_year_width - logical_rect.width / PANGO_SCALE)/2);
+ - (max_year_width - logical_rect.width)/2);
else
x = header_width - (3 + private_data->arrow_width + max_year_width
- - (max_year_width - logical_rect.width / PANGO_SCALE)/2);
+ - (max_year_width - logical_rect.width)/2);
gdk_gc_set_foreground (gc, HEADER_FG_COLOR (GTK_WIDGET (calendar)));
/* Draw month */
sprintf (buffer, "%s", default_monthname[calendar->month]);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (calendar->display_flags & GTK_CALENDAR_NO_MONTH_CHANGE)
- x = 3 + (max_month_width - logical_rect.width / PANGO_SCALE) / 2;
+ x = 3 + (max_month_width - logical_rect.width) / 2;
else
- x = 3 + private_data->arrow_width + (max_month_width - logical_rect.width / PANGO_SCALE)/2;
+ x = 3 + private_data->arrow_width + (max_month_width - logical_rect.width)/2;
gdk_draw_layout (private_data->header_win, gc, x, y, layout);
sprintf (buffer, "%s", default_abbreviated_dayname[day]);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
gdk_draw_layout (private_data->day_name_win, gc,
((private_data->week_width ? CALENDAR_XSEP : CALENDAR_MARGIN)
+ day_wid_sep * i
+ private_data->week_width
- + (day_width - logical_rect.width / PANGO_SCALE)/2),
- CALENDAR_MARGIN + DAY_YPAD + private_data->max_label_char_ascent + logical_rect.y / PANGO_SCALE,
+ + (day_width - logical_rect.width)/2),
+ CALENDAR_MARGIN + DAY_YPAD + private_data->max_label_char_ascent + logical_rect.y,
layout);
}
sprintf (buffer, "%d", week);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- y_loc = top_y_for_row (calendar, row) + (day_height - logical_rect.height / PANGO_SCALE) / 2;
+ y_loc = top_y_for_row (calendar, row) + (day_height - logical_rect.height) / 2;
x_loc = (private_data->week_width
- - logical_rect.width / PANGO_SCALE
+ - logical_rect.width
- CALENDAR_XSEP - DAY_XPAD);
gdk_draw_layout (private_data->week_win, gc, x_loc, y_loc, layout);
sprintf (buffer, "%d", day);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- x_loc -= logical_rect.width / PANGO_SCALE;
+ x_loc -= logical_rect.width;
- y_loc = y_top + (day_height - logical_rect.height / PANGO_SCALE) / 2;
+ y_loc = y_top + (day_height - logical_rect.height) / 2;
gdk_draw_layout (private_data->main_win, gc,
x_loc, y_loc, layout);
if (calendar->marked_date[day-1]
layout = _gtk_clist_create_cell_layout (clist, clist_row, column);
if (layout)
{
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- requisition->width = logical_rect.width / PANGO_SCALE;
- requisition->height = logical_rect.height / PANGO_SCALE;
+ requisition->width = logical_rect.width;
+ requisition->height = logical_rect.height;
g_object_unref (G_OBJECT (layout));
}
if (widget->style->font_desc)
{
- PangoContext *context = gtk_widget_create_pango_context (widget);
+ PangoContext *context = gtk_widget_get_pango_context (widget);
PangoFontMetrics metrics;
PangoFont *font = pango_context_load_font (context, widget->style->font_desc);
gchar *lang = pango_context_get_lang (context);
g_free (lang);
g_object_unref (G_OBJECT (font));
- g_object_unref (G_OBJECT (context));
if (!GTK_CLIST_ROW_HEIGHT_SET(clist))
- clist->row_height = (metrics.ascent + metrics.descent) / PANGO_SCALE;
+ clist->row_height = PANGO_PIXELS (metrics.ascent + metrics.descent);
}
CLIST_REFRESH (clist);
layout = _gtk_clist_create_cell_layout (clist, clist_row, i);
if (layout)
{
- pango_layout_get_extents (layout, NULL, &logical_rect);
- width = logical_rect.width / PANGO_SCALE;
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+ width = logical_rect.width;
}
else
width = 0;
case GTK_CELL_TEXT:
if (layout)
{
- gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height / PANGO_SCALE - 1) / 2;
+ gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height - 1) / 2;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_layout (clist->clist_window, fg_gc,
layout = _gtk_clist_create_cell_layout (clist, clist_row, i);
if (layout)
{
- pango_layout_get_extents (layout, NULL, &logical_rect);
- width = logical_rect.width / PANGO_SCALE;
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+ width = logical_rect.width;
}
else
width = 0;
case GTK_CELL_TEXT:
if (layout)
{
- gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height / PANGO_SCALE - 1) / 2;
+ gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height - 1) / 2;
gdk_gc_set_clip_rectangle (fg_gc, &clip_rectangle);
gdk_draw_layout (clist->clist_window, fg_gc,
if (layout)
{
- gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height / PANGO_SCALE - 1) / 2;
+ gint row_center_offset = 1.5 + (clist->row_height - logical_rect.height - 1) / 2;
if (clist->column[i].justification == GTK_JUSTIFY_RIGHT)
{
layout = _gtk_clist_create_cell_layout (clist, clist_row, column);
if (layout)
{
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- requisition->width = logical_rect.width / PANGO_SCALE;
- requisition->height = logical_rect.height / PANGO_SCALE;
+ requisition->width = logical_rect.width;
+ requisition->height = logical_rect.height;
g_object_unref (G_OBJECT (layout));
}
}
if (entry->layout)
- {
- g_object_unref (G_OBJECT (entry->layout));
- entry->layout = NULL;
- }
+ pango_layout_context_changed (entry->layout);
}
static void
GtkEntry *entry = GTK_ENTRY (widget);
if (entry->layout)
- {
- g_object_unref (G_OBJECT (entry->layout));
- entry->layout = NULL;
- }
+ pango_layout_context_changed (entry->layout);
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
GtkWidget *text_box;
GtkWidget *table, *label;
- fontsel->context = gtk_widget_create_pango_context (GTK_WIDGET (fontsel));
fontsel->font_desc = pango_font_description_from_string ("sans 12");
/* Create the table of font, style & size. */
fontsel = GTK_FONT_SELECTION (object);
- g_object_unref (G_OBJECT (fontsel->context));
pango_font_description_free (fontsel->font_desc);
if (fontsel->font)
gchar **families;
int n_families, i;
- pango_context_list_families (fontsel->context, &families, &n_families);
+ pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
+ &families, &n_families);
qsort (families, n_families, sizeof(char *), cmp_strings);
gtk_clist_freeze (GTK_CLIST (fontsel->font_clist));
gint match_row = 0;
gchar *str;
- pango_context_list_fonts (fontsel->context, fontsel->font_desc->family_name, &descs, &n_descs);
+ pango_context_list_fonts (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
+ fontsel->font_desc->family_name, &descs, &n_descs);
qsort (descs, n_descs, sizeof(PangoFontDescription *), font_description_sort_func);
gtk_clist_freeze (GTK_CLIST (fontsel->font_style_clist));
/* Check to make sure that this is in the list of allowed fonts */
- pango_context_list_fonts (fontsel->context, new_desc->family_name, &descs, &n_descs);
+ pango_context_list_fonts (gtk_widget_get_pango_context (GTK_WIDGET (fontsel)),
+ new_desc->family_name, &descs, &n_descs);
for (i=0; i<n_descs; i++)
{
GtkWidget *filter_button;
GtkWidget *preview_entry;
- PangoContext *context;
PangoFontDescription *font_desc;
GdkFont *font; /* Cache for gdk_font_selection_get_font, so we can preserve
* refcounting behavior
xthickness = widget->style->xthickness;
ythickness = widget->style->ythickness;
- digit_height = ink_rect.height / PANGO_SCALE + 2;
+ digit_height = PANGO_PIXELS (ink_rect.height) + 2;
digit_offset = ink_rect.y;
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, "012456789", -1);
pango_layout_get_extents (layout, &ink_rect, &logical_rect);
- digit_height = ink_rect.height / PANGO_SCALE + 1;
+ digit_height = PANGO_PIXELS (ink_rect.height) + 1;
digit_offset = ink_rect.y;
width = widget->allocation.width;
pango_layout_get_extents (layout, &logical_rect, NULL);
gdk_draw_layout (ruler->backing_store, gc,
- pos + 2, ythickness + (logical_rect.y - digit_offset) / PANGO_SCALE,
+ pos + 2, ythickness + PANGO_PIXELS (logical_rect.y - digit_offset),
layout);
}
}
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
switch (scale->value_pos)
{
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
- x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width / PANGO_SCALE;
- y += (height - logical_rect.height / PANGO_SCALE) / 2;
+ x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width;
+ y += (height - logical_rect.height) / 2;
break;
case GTK_POS_RIGHT:
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, &height);
x += width + SCALE_CLASS (scale)->value_spacing;
- y += (height - logical_rect.height / PANGO_SCALE) / 2;
+ y += (height - logical_rect.height) / 2;
break;
case GTK_POS_TOP:
gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
- x += widget->allocation.x + (width - logical_rect.width / PANGO_SCALE) / 2;
+ x += widget->allocation.x + (width - logical_rect.width) / 2;
x = CLAMP (x, widget->allocation.x,
- widget->allocation.x + widget->allocation.width - logical_rect.width / PANGO_SCALE);
- y -= logical_rect.height / PANGO_SCALE;
+ widget->allocation.x + widget->allocation.width - logical_rect.width);
+ y -= logical_rect.height;
break;
case GTK_POS_BOTTOM:
gdk_window_get_position (GTK_RANGE (scale)->slider, &x, NULL);
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
- x += widget->allocation.x + (width - logical_rect.width / PANGO_SCALE) / 2;
+ x += widget->allocation.x + (width - logical_rect.width) / 2;
x = CLAMP (x, widget->allocation.x,
- widget->allocation.x + widget->allocation.width - logical_rect.width / PANGO_SCALE);
+ widget->allocation.x + widget->allocation.width - logical_rect.width);
y += height;
break;
}
pango_layout_get_extents (label->layout, NULL, &logical_rect);
requisition->width += aux_info->width;
- requisition->height += logical_rect.height / PANGO_SCALE;
+ requisition->height += PANGO_PIXELS (logical_rect.height);
}
else
{
}
pango_layout_set_width (label->layout, width);
- requisition->width += real_width / PANGO_SCALE;
- requisition->height += height / PANGO_SCALE;
+ requisition->width += PANGO_PIXELS (real_width);
+ requisition->height += PANGO_PIXELS (height);
}
}
else /* !label->wrap */
pango_layout_set_width (label->layout, -1);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
- requisition->width += logical_rect.width / PANGO_SCALE;
- requisition->height += logical_rect.height / PANGO_SCALE;
+ requisition->width += PANGO_PIXELS (logical_rect.width);
+ requisition->height += PANGO_PIXELS (logical_rect.height);
}
}
label = GTK_LABEL (widget);
if (previous_style && label->layout)
- {
- g_object_unref (G_OBJECT (label->layout));
- label->layout = NULL;
- }
+ pango_layout_context_changed (label->layout);
}
static void
GtkLabel *label = GTK_LABEL (widget);
if (label->layout)
- {
- g_object_unref (G_OBJECT (label->layout));
- label->layout = NULL;
- }
+ pango_layout_context_changed (label->layout);
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buf, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
g_object_unref (G_OBJECT (layout));
g_free (buf);
{
requisition->width = MAX (MIN_HORIZONTAL_BAR_WIDTH,
2 * widget->style->xthickness + 3 +
- logical_rect.width / PANGO_SCALE + 2 * TEXT_SPACING);
+ logical_rect.width + 2 * TEXT_SPACING);
requisition->height = MAX (MIN_HORIZONTAL_BAR_HEIGHT,
2 * widget->style->ythickness + 3 +
- logical_rect.height / PANGO_SCALE + 2 * TEXT_SPACING);
+ logical_rect.height + 2 * TEXT_SPACING);
}
else
{
{
requisition->width = MAX (MIN_VERTICAL_BAR_WIDTH,
2 * widget->style->xthickness + 3 +
- logical_rect.width / PANGO_SCALE + 2 * TEXT_SPACING);
+ logical_rect.width + 2 * TEXT_SPACING);
requisition->height = MAX (MIN_VERTICAL_BAR_HEIGHT,
2 * widget->style->ythickness + 3 +
- logical_rect.height / PANGO_SCALE + 2 * TEXT_SPACING);
+ logical_rect.height + 2 * TEXT_SPACING);
}
else
{
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buf, -1);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
x = widget->style->xthickness + 1 +
(widget->allocation.width - 2 * widget->style->xthickness -
- 3 - logical_rect.width / PANGO_SCALE)
+ 3 - logical_rect.width)
* progress->x_align;
y = widget->style->ythickness + 1 +
(widget->allocation.height - 2 * widget->style->ythickness -
- 3 - logical_rect.height / PANGO_SCALE)
+ 3 - logical_rect.height)
* progress->y_align;
rect.x = widget->style->xthickness + 1;
buffer[i] = '\0';
pango_layout_set_text (layout, buffer, i);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (width)
- *width = logical_rect.width / PANGO_SCALE;
+ *width = logical_rect.width;
if (height)
- *height = logical_rect.width / PANGO_SCALE;
+ *height = logical_rect.width;
value = ABS (range->adjustment->upper);
if (value == 0) value = 1;
buffer[i] = '\0';
pango_layout_set_text (layout, buffer, i);
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (width)
- *width = MAX (*width, logical_rect.width / PANGO_SCALE);
+ *width = MAX (*width, logical_rect.width);
if (height)
- *height = MAX (*height, logical_rect.height / PANGO_SCALE);
+ *height = MAX (*height, logical_rect.height);
g_object_unref (G_OBJECT (layout));
}
pango_layout_set_text (layout, "012456789", -1);
pango_layout_get_extents (layout, &ink_rect, &logical_rect);
- digit_height = ink_rect.height / PANGO_SCALE + 2;
+ digit_height = PANGO_PIXELS (ink_rect.height) + 2;
digit_offset = ink_rect.y;
width = widget->allocation.height;
gdk_draw_layout (ruler->backing_store, gc,
xthickness + 1,
- pos + digit_height * j + 2 + (logical_rect.y - digit_offset) / PANGO_SCALE,
+ pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset),
layout);
}
}
layout = gtk_widget_create_pango_layout (widget);
pango_layout_set_text (layout, buffer, strlen (buffer));
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
switch (scale->value_pos)
{
gdk_window_get_size (GTK_RANGE (scale)->trough, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->slider, NULL, &height);
- x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width / PANGO_SCALE;
- y += widget->allocation.y + (height - logical_rect.height / PANGO_SCALE) / 2 +
- PANGO_ASCENT (logical_rect) / PANGO_SCALE;
+ x -= SCALE_CLASS (scale)->value_spacing + logical_rect.width;
+ y += widget->allocation.y + (height - logical_rect.height) / 2 +
+ PANGO_ASCENT (logical_rect);
break;
case GTK_POS_RIGHT:
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, NULL);
gdk_window_get_size (GTK_RANGE (scale)->slider, NULL, &height);
x += width + SCALE_CLASS (scale)->value_spacing;
- y += widget->allocation.y + (height - logical_rect.height / PANGO_SCALE) / 2 +
- PANGO_ASCENT (logical_rect) / PANGO_SCALE;
+ y += widget->allocation.y + (height - logical_rect.height) / 2 +
+ PANGO_ASCENT (logical_rect);
break;
case GTK_POS_TOP:
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
- x += (width - logical_rect.width / PANGO_SCALE) / 2;
- y -= PANGO_DESCENT (logical_rect) / PANGO_SCALE;
+ x += (width - logical_rect.width) / 2;
+ y -= PANGO_DESCENT (logical_rect);
break;
case GTK_POS_BOTTOM:
gdk_window_get_position (GTK_RANGE (scale)->trough, &x, &y);
gdk_window_get_size (GTK_RANGE (scale)->slider, &width, NULL);
gdk_window_get_size (GTK_RANGE (scale)->trough, NULL, &height);
- x += (width - logical_rect.width / PANGO_SCALE) / 2;
- y += height + PANGO_ASCENT (logical_rect) / PANGO_SCALE;
+ x += (width - logical_rect.width) / 2;
+ y += height + PANGO_ASCENT (logical_rect);
break;
}
GtkTextDirection previous_direction);
static void gtk_widget_real_grab_focus (GtkWidget *focus_widget);
-static GdkColormap* gtk_widget_peek_colormap (void);
-static GtkStyle* gtk_widget_peek_style (void);
+static GdkColormap* gtk_widget_peek_colormap (void);
+static GtkStyle* gtk_widget_peek_style (void);
+static PangoContext *gtk_widget_peek_pango_context (GtkWidget *widget);
static void gtk_widget_reparent_container_child (GtkWidget *widget,
gpointer client_data);
static guint saved_default_style_key_id = 0;
static const gchar *shape_info_key = "gtk-shape-info";
static const gchar *colormap_key = "gtk-colormap";
+static const gchar *pango_context_key = "gtk-pango-context";
+static guint pango_context_key_id = 0;
static const gchar *rc_style_key = "gtk-rc-style";
static guint rc_style_key_id = 0;
gtk_widget_set_rc_style (widget);
}
+static void
+gtk_widget_direction_changed (GtkWidget *widget,
+ GtkTextDirection previous_direction)
+{
+ gtk_widget_queue_resize (widget);
+}
+
static void
gtk_widget_style_set (GtkWidget *widget,
GtkStyle *previous_style)
gtk_style_set_background (widget->style, widget->window, widget->state);
}
-static void
-gtk_widget_direction_changed (GtkWidget *widget,
- GtkTextDirection previous_direction)
-{
- gtk_widget_queue_resize (widget);
-}
-
static void
gtk_widget_set_style_internal (GtkWidget *widget,
GtkStyle *style,
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (style != NULL);
+
+ if (widget->style != style || initial_emission)
+ {
+ PangoContext *context = gtk_widget_peek_pango_context (widget);
+ if (context)
+ pango_context_set_font_description (context, widget->style->font_desc);
+ }
if (widget->style != style)
{
}
}
+static PangoContext *
+gtk_widget_peek_pango_context (GtkWidget *widget)
+{
+ if (!pango_context_key_id)
+ pango_context_key_id = g_quark_from_static_string (pango_context_key);
+
+ return gtk_object_get_data_by_id (GTK_OBJECT (widget), pango_context_key_id);
+}
+
+/**
+ * gtk_widget_get_pango_context:
+ * @widget: a #GtkWidget
+ *
+ * Get a #PangoContext with the appropriate colormap, font description
+ * and base direction for this widget. Unlike the context returned
+ * by gtk_widget_create_pango_context(), this context is owned by
+ * the widget (it can be used as long as widget exists), and will
+ * be updated to match any changes to the widget's attributes.
+ *
+ * If you create and keep a #PangoLayout using this context, you must
+ * deal with changes to the context by calling pango_layout_context_changed()
+ * on the layout in response to the ::style_set and ::direction_set signals
+ * for the widget.
+ *
+ * Return value: the #PangoContext for the widget.
+ **/
+PangoContext *
+gtk_widget_get_pango_context (GtkWidget *widget)
+{
+ PangoContext *context;
+
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+
+ if (!pango_context_key_id)
+ pango_context_key_id = g_quark_from_static_string (pango_context_key);
+
+ context = gtk_object_get_data_by_id (GTK_OBJECT (widget), pango_context_key_id);
+ if (!context)
+ {
+ context = gtk_widget_create_pango_context (GTK_WIDGET (widget));
+ gtk_object_set_data_by_id_full (GTK_OBJECT (widget), pango_context_key_id, context,
+ (GDestroyNotify)g_object_unref);
+ }
+
+ return context;
+}
+
/**
* gtk_widget_create_pango_context:
* @widget: a #PangoWidget
*
* Create a new pango context with the appropriate colormap,
* font description, and base direction for drawing text for
- * this widget.
+ * this widget. See also gtk_widget_get_pango_context()
*
* Return value: the new #PangoContext
**/
* Create a new #PangoLayout with the appropriate colormap,
* font description, and base direction for drawing text for
* this widget.
+ *
+ * If you keep a #PangoLayout created in this way around, in order
+ * notify the layout of changes to the base direction or font of this
+ * widget, you must call pango_layout_context_changed() in response to
+ * the ::style_set and ::direction_set signals for the widget.
*
* Return value: the new #PangoLayout
**/
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- context = gtk_widget_create_pango_context (widget);
+ context = gtk_widget_get_pango_context (widget);
layout = pango_layout_new (context);
- g_object_unref (G_OBJECT (context));
return layout;
}
return gdk_colormap_get_visual (gtk_widget_get_default_colormap ());
}
+static void
+gtk_widget_emit_direction_changed (GtkWidget *widget,
+ GtkTextDirection old_dir)
+{
+ PangoContext *context = gtk_widget_peek_pango_context (widget);
+
+ if (context)
+ pango_context_set_base_dir (context,
+ gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
+ PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
+
+ gtk_signal_emit (GTK_OBJECT (widget), widget_signals[DIRECTION_CHANGED], old_dir);
+}
+
/**
* gtk_widget_set_direction:
* @widget: a #GtkWidget
}
if (old_dir != gtk_widget_get_direction (widget))
- gtk_signal_emit (GTK_OBJECT (widget), widget_signals[DIRECTION_CHANGED], old_dir);
+ gtk_widget_emit_direction_changed (widget, old_dir);
}
/**
g_object_ref (G_OBJECT (widget));
if (!GTK_WIDGET_DIRECTION_SET (widget))
- gtk_signal_emit (GTK_OBJECT (widget), widget_signals[DIRECTION_CHANGED], old_dir);
+ gtk_widget_emit_direction_changed (widget, old_dir);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
GtkRcStyle *style);
PangoContext *gtk_widget_create_pango_context (GtkWidget *widget);
+PangoContext *gtk_widget_get_pango_context (GtkWidget *widget);
PangoLayout *gtk_widget_create_pango_layout (GtkWidget *widget);
/* handle composite names for GTK_COMPOSITE_CHILD widgets,